import request from '@/utils/request'

// 登录接口
export const userLoginService = ({ username, password }) => {
  return request.post('/admin/common/login', { username, password })
}

// 文件上传
export const fileUploadService = (file) => {
  const formData = new FormData()
  formData.append('file', file)
  return request.post('/admin/common/upload', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 获取当前登录用户信息
export const getCurrentUserService = () => {
  return request.get('/admin/common/me/profile')
}

// 修改当前登录用户信息
export const updateCurrentUserService = (userUpdateDTO) => {
  return request.put('/admin/common/me/profile', userUpdateDTO)
}

// 修改当前登录用户密码
export const updateCurrentUserPasswordService = (password) => {
  return request.post(`/admin/common/me/password/${password}`)
}
